<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后台用户添加</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="__ADMIN__css/bootstrap.min.css" rel="stylesheet">
    <link href="__ADMIN__css/font-awesome.min93e3.css" rel="stylesheet">
    <link href="__ADMIN__css/animate.min.css" rel="stylesheet">
    <link href="__ADMIN__css/style.min.css" rel="stylesheet">
    <link href="__ADMIN__js/plugins/layer/skin/default/layer.css" rel="stylesheet">
    <link href="__ADMIN__css/plugins/cropper/cropper.min.css" rel="stylesheet">
    <link rel="stylesheet" href="__ADMIN__css/plugins/switchery/switchery.css" />
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <form action="{:U('Group/rule')}" method="post" id="forma">
        <input type="hidden" name="id" value="{$id}">
        <div class="col-sm-13">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <foreach name="dataList" item="vo">
                        <div class="row">
                            <label class="checkbox-inline"><input type="checkbox" name="rule_ids[]" value="{$vo['id']}" onclick="checkAll(this)" <if condition="in_array($vo['id'],$rules)">checked</if>>  <h4 style="margin-top: -3px">{$vo['title']}</h4></label>
                            <div class="hr-line-dashed" style="margin-top: -4px;margin-bottom: 6px;"></div>
                            <notempty name="vo['_child']">
                                <foreach name="vo['_child']" item="vos">
                                    <?php $arrNum = count($vos['_child'])?>
                                    <div class="col-sm-{$arrNum+2}" style="padding-left: 0px;font-size: 12px;">
                                        <table class="table table-striped table-bordered table-hover table-condensed tmar">
                                            <tr class="b-group">
                                                <th width="23%"><label>&nbsp;&nbsp;&nbsp;&nbsp;{$vos['title']} <input type="checkbox" name="rule_ids[]" value="{$vos['id']}"  <if condition="in_array($vo['id'],$rules)">checked</if>>
                                                        </label>
                                                </th>
                                                <notempty name="vos['_child']">
                                                    <td>
                                                        <foreach name="vos['_child']" item="v"><label>&nbsp;&nbsp;{$v['title']}&nbsp;&nbsp;<input type="checkbox" name="rule_ids[]" value="{$v['id']}" <if condition="in_array($vo['id'],$rules)">checked</if>></label>
                                                        </foreach>
                                                    </td>
                                                </notempty>
                                            </tr>
                                        </table>
                                    </div>
                                </foreach>
                            </notempty>
                        </div>
                    </foreach>
                    <input type="submit" id="submit" name="submit" value="提交" class="btnsub">
                </div>
            </div>
        </div>
    </form>
</div>
<script src="__ADMIN__js/jquery.min.js"></script>
<script src="__ADMIN__js/bootstrap.min.js"></script>
<script src="__ADMIN__js/plugins/layer/layer.min.js"></script>
<script src="__ADMIN__js/plugins/switchery/switchery.js"></script>
<script src="__ADMIN__js/plugins/validate/jquery.validate.min.js"></script>
<script src="__ADMIN__js/plugins/validate/messages_zh.min.js"></script>
<script src="__ADMIN__js/common.js"></script>
</body>
<script>
    $(function(){
        $('#submit').click(function () {
            var forma = new FormData (document.getElementById('forma'));
            $.ajax({
                url:$('#forma').prop('action'),//获取到form表单action的值
                type:'post',
                dataType:'json',
                data:forma,
                processData: false,
                contentType: false,
                success:function(data){
                    if(data.status > 0){
                        common.error(data.msg);
                    }else{
                        common.success(data.msg,'{:U('group/rule?id='.$id)}');
                    }
                }
            });
            return false;
        })
    });
    function checkAll(obj) {
        $(obj).parents('.row').eq(0).find("input[type='checkbox']").prop('checked',$(obj).prop('checked'));//全选的jq方法
    }
</script>
</html>
